import { Position, TextDocument } from "vscode";
import * as vscode from 'vscode'
import { apis } from "./apis"

function cjHover(document: TextDocument, position: Position) {
    const range = document.getWordRangeAtPosition(position);
    const word = document.getText(range);

    // let selectText = vscode.window.activeTextEditor?.document.getText(vscode.window.activeTextEditor.selection);
    if (word) {
        let check = apis.find(d => d.nameUS == word);
      
        if (check) {
            let docs = `* cj函数 ${check.nameUS}
* 参数  ${check.args}
* 返回值 ${check.returns}
* ${check.title}
* ${check.description}
* ${check.comment}`
            return new vscode.Hover(docs)
        }
    }
    return null
}

export {
    cjHover
}